package ch.zhaw.cctd.domain.prototype;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Representiert ein TowerUpdate Typ und dessen Einstellungen im XML Config File
 * @author Rolf
 * @author Benjamin Felder
 */
public class TowerUpgradePrototype extends Prototype implements Comparable<TowerUpgradePrototype>, Serializable {

	private static final long serialVersionUID = 5133069594697221488L;

	public TowerUpgradePrototype(Map<String, String> data) {
		super(data);
		this.addedEffects = this.getDataList("added-effect", 
				new Prototype.DataListCallback<TowerPrototype.TowerEffectPrototype>() {
					@Override
					public TowerPrototype.TowerEffectPrototype call(String... values) {
						return new TowerPrototype.TowerEffectPrototype(values[0], values[1]);
					}
			}, "type", "#text");

	}
	
	private List<TowerPrototype.TowerEffectPrototype> addedEffects;
	
	public String getImagePath() {
		return this.getValue("image.path");
	}
	
	public int getCost() {
		return this.getIntegerValueWith0("cost");
	}
	
	public int getAddedDamage() {
		return this.getIntegerValueWith0("added-damage.#text");
	}
	
	public int getAddedSpeed() {
		return this.getIntegerValueWith0("added-speed.#text");
	}
	
	public int getAddedRange() {
		return this.getIntegerValueWith0("added-range.#text");
	}
	
	public List<TowerPrototype.TowerEffectPrototype> getAddedEffects() {
		return this.addedEffects;
	}
	
	public List<String> getAbilities() {
		return this.getListValue("added-ability.name");
	}

	@Override
	public int compareTo(TowerUpgradePrototype o) {
		return o.getId().compareTo(this.getId());
	}

}
